package com.rc.saas.tenant.model.market;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.rc.saas.tenant.base.BaseModel;
import com.rc.saas.tenant.common.utils.StringUtil;
import com.rc.saas.tenant.model.converter.ActivityTypeConverter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.util.Date;

public class MarketActivity extends BaseModel {
    /**
     * 状态显示
     */
    @ExcelIgnore
    private String statusString;
    @ExcelIgnore
    private String paymentMethod;
    @ExcelIgnore
    private String clientIsSupported;
    @ExcelIgnore
    private String ticketList;
    @ExcelIgnore
    private Long marketActivityId;
    @ExcelIgnore
    private String tenantCode;

    @ExcelProperty(value = "活动类型",index = 0, converter = ActivityTypeConverter.class)
    private String activityType;

    @ExcelProperty(value = "活动名称",index = 1)
    @NotBlank(message = "活动名称不允许为空")
    private String activityName;

    @ExcelIgnore
    private Long ticketTypeId;

    @ExcelIgnore
    private Integer sendCount;

    @ExcelProperty(value = "活动开始时间",index = 2)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginTime;

    @ExcelProperty(value = "活动结束时间",index = 3)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    @ExcelIgnore
    private String sendType;
    @ExcelIgnore
    private String rewardType;
    @ExcelIgnore
    private Integer maxDiscountCount;
    @ExcelIgnore
    private Integer maxActivityCount;
    @ExcelIgnore
    private String registerPrompt;
    @ExcelIgnore
    private String remark;

    @ExcelIgnore
    private String sendPrompt;
    @ExcelIgnore
    private String status;
    @ExcelIgnore
    private Integer aliPay;
    @ExcelIgnore
    private Integer wxPay;
    @ExcelIgnore
    private Integer unPay;
    @ExcelIgnore
    private Integer abcPay;
    @ExcelIgnore
    private Integer isApp;
    @ExcelIgnore
    private Integer isWx;

    @ExcelProperty(value = "创建人",index = 4)
    private String createdBy;

    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;
    @ExcelIgnore
    private String lastUpdatedBy;
    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdatedTime;

    @ExcelIgnore
    private String activityScope;

    @ExcelIgnore
    private String participateUser;
    @ExcelIgnore
    private String activityImg;
    @ExcelIgnore
    private String activityIndex;
    @ExcelIgnore
    private String activityLink;
    @ExcelIgnore
    private String stationIds;
    @ExcelIgnore
    private String content;
    @ExcelIgnore
    private String sumCondition;
    @ExcelIgnore
    private String chargeLstStr;
    @ExcelIgnore
    private String redutionLstStr;
    @ExcelIgnore
    private String returnLstStr;
    @ExcelIgnore
    private String newLstStr;

    public String getChargeLstStr() {
        return chargeLstStr;
    }

    public void setChargeLstStr(String chargeLstStr) {
        this.chargeLstStr = chargeLstStr;
    }

    public String getRedutionLstStr() {
        return redutionLstStr;
    }

    public void setRedutionLstStr(String redutionLstStr) {
        this.redutionLstStr = redutionLstStr;
    }

    public String getReturnLstStr() {
        return returnLstStr;
    }

    public void setReturnLstStr(String returnLstStr) {
        this.returnLstStr = returnLstStr;
    }

    public String getNewLstStr() {
        return newLstStr;
    }

    public void setNewLstStr(String newLstStr) {
        this.newLstStr = newLstStr;
    }

    public String getStatusString() {

        Date date = new Date();
        long time = date.getTime();
        if (beginTime != null && endTime.toString() != null) {
            if ("1".equals(activityType)) {
                if ("0".equals(status)) {
                    return "停用";
                } else if ("1".equals(status)) {
                    if (beginTime.getTime() > time) {
                        return "未开始";
                    } else if (beginTime.getTime() < time && endTime.getTime() > time) {
                        return "进行中";
                    } else if (endTime.getTime() < time) {
                        return "已结束";
                    }
                }
            } else {
                return status;
            }
        }

        return status;
    }

    public String getPaymentMethod() {
        StringBuilder sb = new StringBuilder();
        if (aliPay == 1) {
            sb.append("支付宝");
            if (wxPay == 1 || unPay == 1 || abcPay == 1) {
                sb.append(",");
            }
        }
        if (wxPay == 1) {
            sb.append("微信");
            if (unPay == 1 || abcPay == 1) {
                sb.append(",");
            }
        }
        if (unPay == 1) {
            sb.append("银联");
            if (abcPay == 1) {
                sb.append(",");
            }
        }
        if (abcPay == 1) {
            sb.append("农行");
        }
        return sb.toString();
    }

    public String getClientIsSupported() {
        StringBuilder stringBuilder = new StringBuilder();
        if (isApp == 1) {
            stringBuilder.append("App");
            if (isWx == 1) {
                stringBuilder.append(",");
            }
        }
        if (isWx == 1) {
            stringBuilder.append("微信公众号");
        }
        return stringBuilder.toString();
    }


    public Integer getMaxActivityCount() {
        return maxActivityCount;
    }

    public void setMaxActivityCount(Integer maxActivityCount) {
        this.maxActivityCount = maxActivityCount;
    }

    public String getActivityScope() {
        return activityScope;
    }

    public String getStationIds() {
        return stationIds;
    }

    public void setStationIds(String stationIds) {
        this.stationIds = stationIds;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSumCondition() {
        return sumCondition;
    }

    public void setSumCondition(String sumCondition) {
        this.sumCondition = sumCondition;
    }

    public void setActivityScope(String activityScope) {
        this.activityScope = activityScope;
    }

    public String getParticipateUser() {
        return participateUser;
    }

    public void setParticipateUser(String participateUser) {
        this.participateUser = participateUser;
    }

    public String getActivityImg() {
        return activityImg;
    }

    public void setActivityImg(String activityImg) {
        this.activityImg = activityImg;
    }

    public String getActivityIndex() {
        return activityIndex;
    }

    public void setActivityIndex(String activityIndex) {
        this.activityIndex = activityIndex;
    }

    public String getActivityLink() {
        return activityLink;
    }

    public void setActivityLink(String activityLink) {
        this.activityLink = activityLink;
    }

    public void setClientIsSupported(String clientIsSupported) {
        this.clientIsSupported = clientIsSupported;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public Integer getAliPay() {
        return aliPay;
    }

    public void setAliPay(Integer aliPay) {
        this.aliPay = aliPay;
    }

    public Integer getWxPay() {
        return wxPay;
    }

    public void setWxPay(Integer wxPay) {
        this.wxPay = wxPay;
    }

    public Integer getUnPay() {
        return unPay;
    }

    public void setUnPay(Integer unPay) {
        this.unPay = unPay;
    }

    public Integer getAbcPay() {
        return abcPay;
    }

    public void setAbcPay(Integer abcPay) {
        this.abcPay = abcPay;
    }

    public Integer getIsApp() {
        return isApp;
    }

    public void setIsApp(Integer isApp) {
        this.isApp = isApp;
    }

    public Integer getIsWx() {
        return isWx;
    }

    public void setIsWx(Integer isWx) {
        this.isWx = isWx;
    }

    public void setStatusString(String statusString) {
        this.statusString = statusString;
    }

    public String getTicketList() {
        return ticketList;
    }

    public void setTicketList(String ticketList) {
        this.ticketList = ticketList;
    }

    public Long getMarketActivityId() {
        return marketActivityId;
    }

    public void setMarketActivityId(Long marketActivityId) {
        this.marketActivityId = marketActivityId;
    }

    @Override
    public String getTenantCode() {
        return tenantCode;
    }

    @Override
    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getActivityType() {
        return activityType;
    }

    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public Long getTicketTypeId() {
        return ticketTypeId;
    }

    public void setTicketTypeId(Long ticketTypeId) {
        this.ticketTypeId = ticketTypeId;
    }

    public Integer getSendCount() {
        return sendCount;
    }

    public void setSendCount(Integer sendCount) {
        this.sendCount = sendCount;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getSendType() {
        return sendType;
    }

    public void setSendType(String sendType) {
        this.sendType = sendType;
    }

    public String getRewardType() {
        return rewardType;
    }

    public void setRewardType(String rewardType) {
        this.rewardType = rewardType;
    }

    public Integer getMaxDiscountCount() {
        return maxDiscountCount;
    }

    public void setMaxDiscountCount(Integer maxDiscountCount) {
        this.maxDiscountCount = maxDiscountCount;
    }

    public String getRegisterPrompt() {
        return registerPrompt;
    }

    public void setRegisterPrompt(String registerPrompt) {
        this.registerPrompt = registerPrompt;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getSendPrompt() {
        return sendPrompt;
    }

    public void setSendPrompt(String sendPrompt) {
        this.sendPrompt = sendPrompt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public String getCreatedBy() {
        return createdBy;
    }

    @Override
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public Date getCreatedTime() {
        return createdTime;
    }

    @Override
    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    @Override
    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    @Override
    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    @Override
    public Date getLastUpdatedTime() {
        return lastUpdatedTime;
    }

    @Override
    public void setLastUpdatedTime(Date lastUpdatedTime) {
        this.lastUpdatedTime = lastUpdatedTime;
    }
}